package com.example.springboot_redis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/redistest")
public class RedisTestController {

    @Autowired
    private RedisTemplate redisTemplate;
    @GetMapping
    public String testRedis(){
        // 设置 key-value 到 redis 里面
        redisTemplate.opsForValue().set("name","luck");
        String name = (String)redisTemplate.opsForValue().get("name");
        return  name;
    }
}
